import leancloud
from leancloud import Object, Query, File

def delmemberpost(pid, real=False):
    post = Query(Object.extend('AgmMemberPost')).get(pid)
    if real:
        for f in post.get('imgfiles'):
            f.destroy()
        query = Query(Object.extend('AgmMemberComment'))
        query.equal_to('memberpost', post)
        for t in query.find():
            t.destroy()
        post.destroy()
    else:
        post.set('status', -1)
        post.save()

def delcomment(pid):
    comment = Query(Object.extend('AgmMemberComment')).get(pid)
    comment.set('status', -1)
    comment.save()